/*
 * MapNode.java
 *
 * Used for A* pathfinding.
 *
 * Copyright 2008 Shawn Xu
 */

package team166;

import battlecode.common.MapLocation;
import battlecode.common.TerrainTile;

public class MapNode implements Comparable
{
  public MapLocation loc;
  public MapNode parent;
  public MapNode child;
  public int F;
  public int G;
  public int H;

  public MapNode()
  {
  }

  public MapNode(MapLocation ml, MapNode p, int g, int h)
  {
    loc = ml;
    parent = p;
    G = g;
    H = h;
    F = G+H;
  }

  public void setG(int g)
  {
    F = (G = g) + H;
  }

  public void setH(int h)
  {
    F = G + (H = h);
  }

  public int compareTo(Object o)
  {
    MapNode object = (MapNode) o;
    if (this.F < object.F) return -1;
    if (this.F == object.F) return 0;
    return 1;
  }
}